package com.hmjk.health.health;

public class BloodSugarAlarm {

	final int MONDAY =0; 
	final int TURSDAY =1; 
	final int WEDNESDAY =2; 
	final int THURSDAY =3; 
	final int FRIDAY =4; 
	final int SATURDAY =5; 
	final int SUNDAY =6; 
	public static final int MAXDAY =7; 
	
	final int DAYBREAK =0; 
	final int BEFOREBREAKFAST =1; 
	final int AFTERBREAKFAST =2; 
	final int BEFORELUNCH =3; 
	final int AFTERLUNCH =4; 
	final int BEFOREDINNER =5; 
	final int AFTERDINNER =6; 
	final int BEFORERETIRING =7; 
	public static final int MAXDETECTION =8; 
	
//	final int ALARM_NONE   =0;
//	final int ALARM_ONE    =1;
//	final int ALARM_ALLDAY =2;
//	final int MAX_ALARM_STATE =3;	

	final int ALARM_NONE   =0;
//	final int ALARM_ONE    =1;
	final int ALARM_ALLDAY =1;
	final int MAX_ALARM_STATE =2;	
	
	
	
	final int CUSTOM_PLAN = 0;
	final int POINT7_PLAN =1; 
	final int POINT5_PLAN =2;
	final int POINT4_PLAN =3;	
	final int THREE_MEC_PLAN  = 4;        //Three meals error correction method
	final int FASTING_HYPERGLYCEMIA_PLAN =5; 
	final int DINING_INFLUENCE_PLAN =6; 
	final int ASYMPTOMATIC_HYPOGLYCEMIA_PLAN =7;   
	final int ALLDAY_PLAN =8;   //
	final int MAXPLAN =9; 		
	
	
	
	final String str_default_alarm[] ={"03:00","06:10","7:30","11:30","13:00","17:50","18:30","22:00"};
	
	String cur_str_alarm[] =new String[MAXDETECTION];
	int cur_plan[][] =new int[MAXDAY][MAXDETECTION];
	
	final int  plan_point7[][]=
		{
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY}, 
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY},
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY},
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};
	
	final int  plan_point5[][]=
		{
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE  }, 
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE  },
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};		

	final int  plan_point4[][]=
		{
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE, ALARM_ALLDAY  }, 
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE, ALARM_ALLDAY  },
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE, ALARM_ALLDAY  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};	
	
	final int  plan_three_mac[][]=
		{
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE  },
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE  },
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};

	final int  plan_fasting[][]=
		{
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY},
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY},
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY},
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};
	
	final int  plan_dining[][]=
		{
			{ALARM_NONE,  ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_ALLDAY, ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};
	
	final int  plan_asymptomatic[][]=
		{
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_ALLDAY, ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};		

	final int  plan_custom[][]=
		{
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};	
	
	final int  plan_allday[][]=
		{
			{ALARM_ALLDAY,ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY}, 
			{ALARM_ALLDAY,ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY},
			{ALARM_ALLDAY,ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY, ALARM_ALLDAY},
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
			{ALARM_NONE,  ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE,   ALARM_NONE  },
		};	
	
	final int allplan[][][]={
			                 cur_plan,
			                 plan_point7,
			                 plan_point5,
			                 plan_point4,
			                 plan_three_mac,
			                 plan_fasting,
			                 plan_dining,
			                 plan_asymptomatic,
			                 plan_allday
			                 }	;
	
	public BloodSugarAlarm() {
		// TODO Auto-generated constructor stub
		Set_plan(plan_custom);
	}

	public int[][] Getdatafromplan(int plan)
	{
		if((plan>=0)&&(plan<MAXPLAN))
		{	
		return allplan[plan];
		}
		else
		{
			return cur_plan;
		}	
	}
	
	public boolean is_same_plan(int [][] curplan,int [][] cmpplan)	
	{
		boolean bresult =true;
		for(int i=0;i<MAXDAY;i++)
		{
			for(int j=0;j<MAXDETECTION;j++)
			{
				if(curplan[i][j]!=cmpplan[i][j])
				{
					bresult =false;
					break;
				}	
			}	
		}	
		return bresult;
	}
	


	public void Set_plan(int [][] curplan)	
	{
//		boolean bresult =true;
		for(int i=0;i<MAXDAY;i++)
		{
			for(int j=0;j<MAXDETECTION;j++)
			{
				cur_plan[i][j]=curplan[i][j];
			}	
		}	
//		return bresult;
	}
	

	public int Get_plan(int [][] curplan)
	{
		if(is_same_plan(curplan,plan_point7))
		{
			return POINT7_PLAN;
		}	
		if(is_same_plan(curplan,plan_point5))
		{
			return POINT5_PLAN;
		}
		if(is_same_plan(curplan,plan_three_mac))
		{
			return THREE_MEC_PLAN;
		}
		if(is_same_plan(curplan,plan_fasting))
		{
			return FASTING_HYPERGLYCEMIA_PLAN;
		}
		if(is_same_plan(curplan,plan_dining))
		{
			return DINING_INFLUENCE_PLAN;
		}	
		if(is_same_plan(curplan,plan_asymptomatic))
		{
			return ASYMPTOMATIC_HYPOGLYCEMIA_PLAN;
		}		  
		return CUSTOM_PLAN;
	}
}
